<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
-->
<template>
  <div>
    <!-- <template #title>
      <Icon :icon="getTitle.icon" class="m-1 pr-1" />
      <span> {{ getTitle.value }} </span>
    </template> -->
    <BasicTable @register="registerTable" @row-click="handleRdrecordRowClick">
      <template #toolbar>
        <a-button type="default" @click="handleExport()">
          <!-- <EyeOutlined /> -->
          <Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
        </a-button>
      </template>
      <template #headerCell="{ column }">
        <template v-if="column.dataIndex === 'tzQty'">
          <span class="fontWeight-bold">
            {{ column.customTitle }}
          </span>
        </template>
        <template v-else>
          {{ column.customTitle }}
        </template>
      </template>
    </BasicTable>
  </div>
</template>
<script lang="ts">
  export default defineComponent({
    name: 'ViewsRdRd32Rdrecord32InvList',
  });
</script>
<script lang="ts" setup>
  import { unref, defineComponent, ref, computed } from 'vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { router } from '/@/router';
  import { Icon } from '/@/components/Icon';
  import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
  import { companyTreeData } from '/@/api/sys/company';
  import { useGlobSetting } from '/@/hooks/setting';
  import { downloadByUrl } from '/@/utils/file/download';
  import { useDrawer } from '/@/components/Drawer';
  import { useModal } from '/@/components/Modal';
  import { FormProps } from '/@/components/Form';
  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import { listProspect } from '/@/api/wms/jh/plan/jhPlanArea';
  import { Table } from 'ant-design-vue';
  const { t } = useI18n('rd.rd32.rdrecord32');
  const { showMessage } = useMessage();
  const { meta } = unref(router.currentRoute);
  const emit = defineEmits(['success', 'register']);

  const getTitle = {
    icon: meta.icon || 'i-ant-design:book-outlined',
    value: t('库存展望查询'),
  };
  const tableColumns: BasicColumn[] = [
    {
      title: t('销售订单号'),
      dataIndex: 'forderno',
      key: 'a.forderno',
      sorter: true,
      width: 120,
      align: 'left',
    },
    {
      title: t('发货单号'),
      dataIndex: 'parent.fbillno',
      key: 'parent.fbillno',
      sorter: true,
      width: 110,
      align: 'left',
    },
    {
      title: t('联系人'),
      dataIndex: 'fperson',
      key: 'a.fperson',
      sorter: true,
      width: 80,
      align: 'left',
    },
    {
      title: t('地址'),
      dataIndex: 'faddress',
      key: 'a.faddress',
      sorter: true,
      width: 160,
      align: 'left',
    },
    {
      title: t('电话'),
      dataIndex: 'fphone',
      key: 'a.fphone',
      sorter: true,
      width: 100,
      align: 'left',
    },
    {
      title: t('商品编码'),
      dataIndex: 'fitemno',
      key: 'a.fitemno',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('商品名称'),
      dataIndex: 'fitemname',
      key: 'a.fitemname',
      sorter: true,
      width: 150,
      align: 'left',
    },
    {
      title: t('形象刊'),
      dataIndex: 'freeVO.cfree1',
      width: 130,
      align: 'left',
    },
    {
      title: t('应拣数量'),
      dataIndex: 'fqty',
      key: 'a.fqty',
      sorter: true,
      width: 130,
      align: 'left',
      showSummary: true,
    },
    {
      title: t('现存量'),
      dataIndex: 'xcQty',
      key: 'a.xcQty',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('差缺数'),
      dataIndex: 'xclDiffQty',
      key: 'a.xclDiffQty',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('可拣货数'),
      dataIndex: 'pickQty',
      key: 'a.pickQty',
      sorter: true,
      width: 130,
      align: 'left',
      showSummary: true,
    },
  ];

  const searchForm: FormProps = {
    baseColProps: { lg: 8, md: 8 },
    labelWidth: 90,
    // showResetButton:false,
    schemas: [
      {
        label: t('商品编码'),
        field: 'fitemno',
        component: 'Input',
      },
      {
        label: t('商品名称'),
        field: 'fitemname',
        component: 'Input',
      },
    ],
  };

  // const [registerDrawer, { openDrawer }] = useDrawer();
  const [registerTable, { reload, setProps, getDataSource, getForm }] = useTable({
    api: listProspect,
    beforeFetch: (params) => {
      console.log('params', params);
      return params;
    },
    columns: tableColumns,
    // maxHeight: 800,
    // actionColumn: actionColumn,
    formConfig: searchForm,
    pagination: true,
    showTableSetting: false,
    useSearchForm: true,
    canResize: true,
    immediate: true,
    showCustomSummary: true,
    // resizeHeightOffset: 70
  });

  function handleRdrecordRowClick(record: Recordable) {
    record.onEdit?.(true, false);
  }
  async function handleExport() {
    const { ctxAdminPath } = useGlobSetting();
    downloadByUrl({
      url: ctxAdminPath + '/jh/plan/jhPlanArea/prospectExport',
      params: getForm().getFieldsValue(),
    });
  }
</script>
<style scoped>
  .ant-input {
    border: 1px solid red !important;
  }
  .fontWeight-bold {
    font-weight: bold;
  }
</style>
